package com.gree.elasticsearch.controller;

import com.gree.elasticsearch.domain.Foo;
import com.gree.elasticsearch.service.DefaultFooService;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 总有刁民想害朕，请叫我小花狗
 * create by zxw on 2020/5/22
 */
@RestController
@RequestMapping("/foo")
public class FooController implements InitializingBean {
    @Autowired
    private DefaultFooService fooService;
    private final String RESPONSE_MESSAGE = "OK";
    private Foo foo;

    @GetMapping
    public String getFoo() {
        fooService.createFooByJdbTemplate();
        return RESPONSE_MESSAGE;
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        foo = new Foo();
        foo.setName(Thread.currentThread().getName());
    }
}
